/**
 * 安卓白金英雄坛制作组 <br>
 * 文件名：TriggerCondition.java <br>
 * 创建时间：2015-3-7 下午12:59:32 <br>
 * 所属项目：GmudEX <br>
 * @author 12548 <br>
 */
package lostland.gmud.exv2.data;

import lostland.gmud.exv2.Game;
import lostland.gmud.exv2.Gmud;

/**
 * 类名：TriggerCondition <br>
 * 说明：
 *
 * @author 12548
 */
public class TriggerCondition {

	public int conditionID = 0;

	public boolean boolArg = false;
	public int intArg1 = 0;
	public int intArg2 = 0;
	public int intArg3 = 0;


	public static final int COND_BOOL = 0;
	public static final int COND_SWITCH = 1;
	public static final int COND_TEMP_SWITCH = 2;
	public static final int COND_NOT = 3;
	public static final int COND_OR = 4;
	public static final int COND_AND = 5;
	public static final int COND_MAINCHAR_ATTR = 6;
	public static final int COND_MAINCHAR_ATTR_VAR = 7;
	public static final int COND_MAINCHAR_ATTR_TEMP_VAR = 8;
	public static final int COND_MAINCHAR_SKILL_LV = 9;

	public boolean check() {
		switch (conditionID) {
			case COND_BOOL:
				return boolArg;
			case COND_SWITCH:
				return Game.getData().game_switch.get(intArg1) == boolArg;
			case COND_TEMP_SWITCH:
				return Gmud.temp_switches.get(intArg1) == boolArg;
			case COND_NOT:
				return !Gmud.conditions.get(intArg1).check();
			case COND_AND:
				return Gmud.conditions.get(intArg1).check() && Gmud.conditions.get(intArg2).check();
			case COND_OR:
				return Gmud.conditions.get(intArg1).check() || Gmud.conditions.get(intArg2).check();
			case COND_MAINCHAR_ATTR: {
				boolean b = false;
				switch (intArg2) {
					case 0:
						b = Gmud.mc.getAttr(intArg1) > intArg3;
						break;
					case 1:
						b = Gmud.mc.getAttr(intArg1) == intArg3;
						break;
					case 2:
						b = Gmud.mc.getAttr(intArg1) < intArg3;
				}
				return b == boolArg;
			}
			case COND_MAINCHAR_ATTR_VAR: {
				boolean b = false;
				switch (intArg2) {
					case 0:
						b = Gmud.mc.getAttr(intArg1) > Game.getData().game_variavble.get(intArg3);
						break;
					case 1:
						b = Gmud.mc.getAttr(intArg1) == Game.getData().game_variavble.get(intArg3);
						break;
					case 2:
						b = Gmud.mc.getAttr(intArg1) < Game.getData().game_variavble.get(intArg3);
				}
				return b == boolArg;
			}
			case COND_MAINCHAR_ATTR_TEMP_VAR: {
				boolean b = false;
				switch (intArg2) {
					case 0:
						b = Gmud.mc.getAttr(intArg1) > Game.getData().game_variavble.get(intArg3);
						break;
					case 1:
						b = Gmud.mc.getAttr(intArg1) == Game.getData().game_variavble.get(intArg3);
						break;
					case 2:
						b = Gmud.mc.getAttr(intArg1) < Game.getData().game_variavble.get(intArg3);
				}
				return b == boolArg;
			}
			case COND_MAINCHAR_SKILL_LV: {
				boolean b = false;
				switch (intArg2) {
					case 0:
						b = Gmud.mc.skills[intArg1] > intArg3;
						break;
					case 1:
						b = Gmud.mc.skills[intArg1] == intArg3;
						break;
					case 2:
						b = Gmud.mc.skills[intArg1] < intArg3;
				}
				return b == boolArg;
			}
		}
		return true;
	}

}
